package admin

import (
	api "ruoyi-go/app/admin/api/system"
	"ruoyi-go/app/admin/router/monitor"
	"ruoyi-go/app/admin/router/system"
	"ruoyi-go/app/admin/router/tools"
	"ruoyi-go/utils/jwt"
	"time"

	cache "github.com/chenyahui/gin-cache"
	"github.com/chenyahui/gin-cache/persist"
	"github.com/gin-gonic/gin"
)

func Routers(e *gin.Engine) {
	memoryStore := persist.NewMemoryStore(1 * time.Minute)
	handlerFunc := cache.CacheByRequestURI(memoryStore, 2*time.Second)

	v1 := e.Group("")
	{
		auth := v1.Group("")
		auth.Use(jwt.AuthMiddleware())
		{
			/*获取用户信息*/
			auth.GET("/getInfo", handlerFunc, api.GetInfoHandler)
			/*获取用户授权菜单*/
			auth.GET("/getRouters", handlerFunc, api.GetRoutersHandler)

			/*system*/
			system.InitProfile(auth)
			system.InitDict(auth)
			system.InitUser(auth)
			system.InitMenu(auth)
			system.InitPost(auth)
			system.InitNotice(auth)
			system.InitRole(auth)
			system.InitConfig(auth)
			system.InitDept(auth)
			system.InitWechat(auth)

			/*monitor*/
			monitor.InitCache(auth)
			monitor.InitLogininfor(auth)
			monitor.InitJob(auth)
			monitor.InitJobLog(auth)
			monitor.InitOnLine(auth)
			monitor.InitOperlog(auth)
			monitor.InitServer(auth)

			/*tools*/
			tools.InitCommon(auth)
			tools.InitGen(auth)

			/*文件管理*/
			//file.InitFile(e)

			/*business业务路由*/
		}
	}
}
